package com.itheima.service;


import com.itheima.excption.MyException;
import com.itheima.pojo.SmsFlashPromotionSession;
import com.itheima.vo.Result;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SmsFlashPromotionSessionService {

    @DubboReference
    private SmsFlashPromotionSessionApi smsFlashPromotionSessionApi;


    /**
     * 删除场次
     * @param id
     * @return
     */
    public void deleteByIds(Integer id) {
        smsFlashPromotionSessionApi.deleteByIds(id);
    }

    /**
     * 添加场次
     * @param smsFlashPromotionSession
     * @return
     */
    public void save(SmsFlashPromotionSession smsFlashPromotionSession) {
        boolean flag = smsFlashPromotionSessionApi.save(smsFlashPromotionSession);
        if (flag){
            throw new MyException("该名称已存在，请重试!");
        }
    }

    /**
     * 修改启用的状态
     * @param status
     * @param id
     * @return
     */
    public void updateStatus(Integer status, Integer id) {
        smsFlashPromotionSessionApi.updateStatus(status,id);
    }

    /**
     * 获取全部场次
     * @return
     */
    public List<SmsFlashPromotionSession> listAll() {
        List<SmsFlashPromotionSession> list = smsFlashPromotionSessionApi.listAll();
        return list;
    }

    /**
     * 获取场次详情
     * @param id
     * @return
     */
    public SmsFlashPromotionSession findById(Integer id) {
        SmsFlashPromotionSession smsFlashPromotionSession = smsFlashPromotionSessionApi.findById(id);
        return smsFlashPromotionSession;
    }

    /**
     * 修改场次
     * @param id
     * @param smsFlashPromotionSession
     * @return
     */
    public void updateSession(Integer id, SmsFlashPromotionSession smsFlashPromotionSession) {
        smsFlashPromotionSessionApi.updateSession(id,smsFlashPromotionSession);
    }

    /**
     * 获取全部可选场次及其数量
     * @param flashPromotionId
     * @return
     */
    public Result selectList(Integer flashPromotionId) {
        Map map=smsFlashPromotionSessionApi.selectList(flashPromotionId);
        return null;
    }
}
